package com.indusfo.spc.client.mapper;

import com.indusfo.spc.pojo.OrderFlow;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author chenm
 * @create 2019-12-06 16:09
 */
public interface ClientOrderFlowMapper {


	/**
	 * 查询剩余工序（型号变更用）
	 * 
	 * @param orderTechId
	 * @param serialNum
	 * @author zhengd
	 * @return OrderFlow
	 */
	List<OrderFlow> queryProList(@Param("orderTechId") Integer orderTechId, @Param("serialNum") Integer serialNum);
	
	/**
	 * 查询剩余工序（包含维修工序）
	 * 
	 * @param orderTechId
	 * @param serialNum
	 * @author zhengd
	 * @return OrderFlow
	 */
	List<OrderFlow> queryRemainProList(@Param("orderTechId") Integer orderTechId, @Param("serialNum") Integer serialNum);
	
	/**
	 * 查询已完工工序（型号变更用）
	 * 
	 * @param orderTechId
	 * @param serialNum
	 * @author zhengd
	 * @return OrderFlow
	 */
	List<OrderFlow> queryFinishProList(@Param("orderTechId") Integer orderTechId, @Param("serialNum") Integer serialNum);

  List<OrderFlow> selectByOrderTechId( @Param("orderTechId") Integer orderTechId);

  OrderFlow currentProByOrderTechIdNotInOrderFlowId(@Param("orderTechId") Integer orderTechId, @Param("orderFlowIds") List<Integer> orderFlowIds);


  List<OrderFlow> selectByOrderTechIdAndSequence(@Param("orderTechId") Integer orderTechId, @Param("sequence") Integer sequence);

  OrderFlow selectByOrderFlowId(@Param("orderFlowId") Integer orderFlowId);

  List<OrderFlow> nextOrderFlowByCurrentOrderFlowId(@Param("orderFlowId") Integer orderFlowId,@Param("orderTechId") Integer orderTechId);

  List<OrderFlow> restOrderFlowByCurrentOrderFlowId(@Param("orderFlowId")Integer orderFlowId, @Param("orderTechId") Integer orderTechId);

  List<Integer> selectOrderFlowIdByOrderRepairId(@Param("orderRepairId") Integer orderRepairId,@Param("orderTechId") Integer orderTechId);

  Integer selectOrderFlowIdByOrderTechId(@Param("orderTechId") Integer orderTechId,@Param("serialNum") Integer serialNum);
	/**
	 * 查询最后一道已完成工序（型号变更用）
	 *
	 * @param batchId
	 * @author zhengd
	 * @return OrderFlow
	 */
  OrderFlow queryLastOrderFlowByBatchId(@Param("batchId") Integer batchId);

  Integer deleteOrderFlowByOrderFlowId(@Param("orderFlowId") Integer orderFlowId);
  
  Integer querySerialNumByProId(@Param("proId") Integer proId,@Param("orderTechId") Integer orderTechId);

  List<OrderFlow> restOrderFlowByOrderTechId(@Param("orderTechId") Integer orderTechId,@Param("batchId") Integer batchId);
}
